package org.study.springboot.exception.handler.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.study.springboot.exception.handler.constant.Status;
import org.study.springboot.exception.handler.exception.JSONException;
import org.study.springboot.exception.handler.exception.PageException;
import org.study.springboot.exception.handler.model.APIResponse;

/**
 * @author fangyu
 * @version v1.0.0
 * @date 2020/11/18 1:57 下午
 */
@Controller
public class TestController {

    @GetMapping("/json")
    @ResponseBody
    public APIResponse jsonException() {
        throw new JSONException(Status.UNKNOWN_ERROR);
    }

    @GetMapping("/page")
    public ModelAndView pageException() {
        throw new PageException(Status.UNKNOWN_ERROR);
    }
}